From 74f9c39d10b3e2d56b6f70ce2b1174fded50c0c5 Mon Sep 17 00:00:00 2001 From: "ach61@labyrinth.cl.cam.ac.uk" Date: Fri, 13 Feb 2004 20:50:45 +0000 Subject: [PATCH] bitkeeper revision 1.726 (402d38a5ev6IHCrkovur_GS1Iinquw) allow gdb to change registers --- docs/pdb.txt | 2 +- xen/arch/i386/pdb-stub.c | 202 ++++++++++++------ .../arch/xeno/drivers/block/xl_block.c | 5 + 3 files changed, 141 insertions(+), 68 deletions(-) diff --git a/docs/pdb.txt b/docs/pdb.txt index aab57c5a42..6eb91096b1 100644 --- a/docs/pdb.txt +++ b/docs/pdb.txt @@ -1,7 +1,7 @@ Pervasive Debugging =================== -040205 Alex Ho (alex.ho@cl.cam.ac.uk) +040205 Alex Ho (alex.ho at cl.cam.ac.uk) Introduction ------------ diff --git a/xen/arch/i386/pdb-stub.c b/xen/arch/i386/pdb-stub.c index a9355cb185..f56abae004 100644 --- a/xen/arch/i386/pdb-stub.c +++ b/xen/arch/i386/pdb-stub.c @@ -118,6 +118,81 @@ pdb_process_query (char *ptr) } } +void +pdb_x86_to_gdb_regs (char *buffer, struct pt_regs *regs) +{ + int idx = 0; + + mem2hex ((char *)®s->eax, &buffer[idx], sizeof(regs->eax)); + idx += sizeof(regs->eax) * 2; + mem2hex ((char *)®s->ecx, &buffer[idx], sizeof(regs->ecx)); + idx += sizeof(regs->ecx) * 2; + mem2hex ((char *)®s->edx, &buffer[idx], sizeof(regs->edx)); + idx += sizeof(regs->edx) * 2; + mem2hex ((char *)®s->ebx, &buffer[idx], sizeof(regs->ebx)); + idx += sizeof(regs->ebx) * 2; + mem2hex ((char *)®s->esp, &buffer[idx], sizeof(regs->esp)); + idx += sizeof(regs->esp) * 2; + mem2hex ((char *)®s->ebp, &buffer[idx], sizeof(regs->ebp)); + idx += sizeof(regs->ebp) * 2; + mem2hex ((char *)®s->esi, &buffer[idx], sizeof(regs->esi)); + idx += sizeof(regs->esi) * 2; + mem2hex ((char *)®s->edi, &buffer[idx], sizeof(regs->edi)); + idx += sizeof(regs->edi) * 2; + mem2hex ((char *)®s->eip, &buffer[idx], sizeof(regs->eip)); + idx += sizeof(regs->eip) * 2; + mem2hex ((char *)®s->eflags, &buffer[idx], sizeof(regs->eflags)); + idx += sizeof(regs->eflags) * 2; + mem2hex ((char *)®s->xcs, &buffer[idx], sizeof(regs->xcs)); + idx += sizeof(regs->xcs) * 2; + mem2hex ((char *)®s->xss, &buffer[idx], sizeof(regs->xss)); + idx += sizeof(regs->xss) * 2; + mem2hex ((char *)®s->xds, &buffer[idx], sizeof(regs->xds)); + idx += sizeof(regs->xds) * 2; + mem2hex ((char *)®s->xes, &buffer[idx], sizeof(regs->xes)); + idx += sizeof(regs->xes) * 2; + mem2hex ((char *)®s->xfs, &buffer[idx], sizeof(regs->xfs)); + idx += sizeof(regs->xfs) * 2; + mem2hex ((char *)®s->xgs, &buffer[idx], sizeof(regs->xgs)); +} + +/* at this point we allow any register to be changed, caveat emptor */ +void +pdb_gdb_to_x86_regs (struct pt_regs *regs, char *buffer) +{ + hex2mem(buffer, (char *)®s->eax, sizeof(regs->eax)); + buffer += sizeof(regs->eax) * 2; + hex2mem(buffer, (char *)®s->ecx, sizeof(regs->ecx)); + buffer += sizeof(regs->ecx) * 2; + hex2mem(buffer, (char *)®s->edx, sizeof(regs->edx)); + buffer += sizeof(regs->edx) * 2; + hex2mem(buffer, (char *)®s->ebx, sizeof(regs->ebx)); + buffer += sizeof(regs->ebx) * 2; + hex2mem(buffer, (char *)®s->esp, sizeof(regs->esp)); + buffer += sizeof(regs->esp) * 2; + hex2mem(buffer, (char *)®s->ebp, sizeof(regs->ebp)); + buffer += sizeof(regs->ebp) * 2; + hex2mem(buffer, (char *)®s->esi, sizeof(regs->esi)); + buffer += sizeof(regs->esi) * 2; + hex2mem(buffer, (char *)®s->edi, sizeof(regs->edi)); + buffer += sizeof(regs->edi) * 2; + hex2mem(buffer, (char *)®s->eip, sizeof(regs->eip)); + buffer += sizeof(regs->eip) * 2; + hex2mem(buffer, (char *)®s->eflags, sizeof(regs->eflags)); + buffer += sizeof(regs->eflags) * 2; + hex2mem(buffer, (char *)®s->xcs, sizeof(regs->xcs)); + buffer += sizeof(regs->xcs) * 2; + hex2mem(buffer, (char *)®s->xss, sizeof(regs->xss)); + buffer += sizeof(regs->xss) * 2; + hex2mem(buffer, (char *)®s->xds, sizeof(regs->xds)); + buffer += sizeof(regs->xds) * 2; + hex2mem(buffer, (char *)®s->xes, sizeof(regs->xes)); + buffer += sizeof(regs->xes) * 2; + hex2mem(buffer, (char *)®s->xfs, sizeof(regs->xfs)); + buffer += sizeof(regs->xfs) * 2; + hex2mem(buffer, (char *)®s->xgs, sizeof(regs->xgs)); +} + int pdb_process_command (char *ptr, struct pt_regs *regs) { @@ -139,84 +214,77 @@ pdb_process_command (char *ptr, struct pt_regs *regs) pdb_out_buffer[2] = hexchars[sigval % 16]; pdb_out_buffer[3] = 0; break; - case 'S': /* step with signal */ - case 's': /* step */ + case 'S': /* step with signal */ + case 's': /* step */ regs->eflags |= 0x100; pdb_stepping = 1; return 1; /* not reached */ - case 'C': /* continue with signal */ - case 'c': /* continue */ + case 'C': /* continue with signal */ + case 'c': /* continue */ regs->eflags &= ~0x100; /* jump out before replying to gdb */ return 1; /* not reached */ case 'd': - remote_debug = !(remote_debug); /* toggle debug flag */ + remote_debug = !(remote_debug); /* toggle debug flag */ break; - case 'D': /* detach */ + case 'D': /* detach */ return go; /* not reached */ - case 'g': /* return the value of the CPU registers */ - { - int idx = 0; - mem2hex ((char *)®s->eax, &pdb_out_buffer[idx], sizeof(regs->eax)); - idx += sizeof(regs->eax) * 2; - mem2hex ((char *)®s->ecx, &pdb_out_buffer[idx], sizeof(regs->ecx)); - idx += sizeof(regs->ecx) * 2; - mem2hex ((char *)®s->edx, &pdb_out_buffer[idx], sizeof(regs->edx)); - idx += sizeof(regs->edx) * 2; - mem2hex ((char *)®s->ebx, &pdb_out_buffer[idx], sizeof(regs->ebx)); - idx += sizeof(regs->ebx) * 2; - mem2hex ((char *)®s->esp, &pdb_out_buffer[idx], sizeof(regs->esp)); - idx += sizeof(regs->esp) * 2; - mem2hex ((char *)®s->ebp, &pdb_out_buffer[idx], sizeof(regs->ebp)); - idx += sizeof(regs->ebp) * 2; - mem2hex ((char *)®s->esi, &pdb_out_buffer[idx], sizeof(regs->esi)); - idx += sizeof(regs->esi) * 2; - mem2hex ((char *)®s->edi, &pdb_out_buffer[idx], sizeof(regs->edi)); - idx += sizeof(regs->edi) * 2; - mem2hex ((char *)®s->eip, &pdb_out_buffer[idx], sizeof(regs->eip)); - idx += sizeof(regs->eip) * 2; - mem2hex ((char *)®s->eflags, &pdb_out_buffer[idx], sizeof(regs->eflags)); - idx += sizeof(regs->eflags) * 2; - mem2hex ((char *)®s->xcs, &pdb_out_buffer[idx], sizeof(regs->xcs)); - idx += sizeof(regs->xcs) * 2; - mem2hex ((char *)®s->xss, &pdb_out_buffer[idx], sizeof(regs->xss)); - idx += sizeof(regs->xss) * 2; - mem2hex ((char *)®s->xds, &pdb_out_buffer[idx], sizeof(regs->xds)); - idx += sizeof(regs->xds) * 2; - mem2hex ((char *)®s->xes, &pdb_out_buffer[idx], sizeof(regs->xes)); - idx += sizeof(regs->xes) * 2; - mem2hex ((char *)®s->xfs, &pdb_out_buffer[idx], sizeof(regs->xfs)); - idx += sizeof(regs->xfs) * 2; - mem2hex ((char *)®s->xgs, &pdb_out_buffer[idx], sizeof(regs->xgs)); - - /* - TRC(printk (" reg: %s \n", pdb_out_buffer)); - TRC(printk (" ebx: 0x%08lx\n", regs->ebx)); - TRC(printk (" ecx: 0x%08lx\n", regs->ecx)); - TRC(printk (" edx: 0x%08lx\n", regs->edx)); - TRC(printk (" esi: 0x%08lx\n", regs->esi)); - TRC(printk (" edi: 0x%08lx\n", regs->edi)); - TRC(printk (" ebp: 0x%08lx\n", regs->ebp)); - TRC(printk (" eax: 0x%08lx\n", regs->eax)); - TRC(printk (" xds: 0x%08x\n", regs->xds)); - TRC(printk (" xes: 0x%08x\n", regs->xes)); - TRC(printk (" xfs: 0x%08x\n", regs->xfs)); - TRC(printk (" xgs: 0x%08x\n", regs->xgs)); - TRC(printk (" eip: 0x%08lx\n", regs->eip)); - TRC(printk (" xcs: 0x%08x\n", regs->xcs)); - TRC(printk (" efl: 0x%08lx\n", regs->eflags)); - TRC(printk (" esp: 0x%08lx\n", regs->esp)); - TRC(printk (" xss: 0x%08x\n", regs->xss)); - */ + case 'g': /* return the value of the CPU registers */ + { + pdb_x86_to_gdb_regs (pdb_out_buffer, regs); + + /* + printk (" reg: %s", pdb_out_buffer); + printk ("\n"); + printk (" eax: 0x%08lx\n", regs->eax); + printk (" ecx: 0x%08lx\n", regs->ecx); + printk (" edx: 0x%08lx\n", regs->edx); + printk (" ebx: 0x%08lx\n", regs->ebx); + printk (" esp: 0x%08lx\n", regs->esp); + printk (" ebp: 0x%08lx\n", regs->ebp); + printk (" esi: 0x%08lx\n", regs->esi); + printk (" edi: 0x%08lx\n", regs->edi); + printk (" eip: 0x%08lx\n", regs->eip); + printk (" efl: 0x%08lx\n", regs->eflags); + printk (" xcs: 0x%08x\n", regs->xcs); + printk (" xss: 0x%08x\n", regs->xss); + printk (" xds: 0x%08x\n", regs->xds); + printk (" xes: 0x%08x\n", regs->xes); + printk (" xfs: 0x%08x\n", regs->xfs); + printk (" xgs: 0x%08x\n", regs->xgs); + */ break; } - case 'G': /* set the value of the CPU registers - return OK */ - break; + case 'G': /* set the value of the CPU registers - return OK */ + { + pdb_gdb_to_x86_regs (regs, ptr); + + /* + printk (" ptr: %s \n\n", ptr); + printk (" eax: 0x%08lx\n", regs->eax); + printk (" ecx: 0x%08lx\n", regs->ecx); + printk (" edx: 0x%08lx\n", regs->edx); + printk (" ebx: 0x%08lx\n", regs->ebx); + printk (" esp: 0x%08lx\n", regs->esp); + printk (" ebp: 0x%08lx\n", regs->ebp); + printk (" esi: 0x%08lx\n", regs->esi); + printk (" edi: 0x%08lx\n", regs->edi); + printk (" eip: 0x%08lx\n", regs->eip); + printk (" efl: 0x%08lx\n", regs->eflags); + printk (" xcs: 0x%08x\n", regs->xcs); + printk (" xss: 0x%08x\n", regs->xss); + printk (" xds: 0x%08x\n", regs->xds); + printk (" xes: 0x%08x\n", regs->xes); + printk (" xfs: 0x%08x\n", regs->xfs); + printk (" xgs: 0x%08x\n", regs->xgs); + */ + break; + } case 'H': { int thread; @@ -244,9 +312,9 @@ pdb_process_command (char *ptr, struct pt_regs *regs) strcpy (pdb_out_buffer, "OK"); break; } - case 'k': /* kill request */ + case 'k': /* kill request */ { - strcpy (pdb_out_buffer, "OK"); /* ack for fun */ + strcpy (pdb_out_buffer, "OK"); /* ack for fun */ printk ("don't kill bill...\n"); ack = 0; break; @@ -325,9 +393,9 @@ pdb_process_command (char *ptr, struct pt_regs *regs) int thread; if (hexToInt (&ptr, &thread)) { - struct task_struct *p; + struct task_struct *p; thread -= PDB_DOMAIN_OFFSET; - if ( (p = find_domain_by_id(thread)) == NULL ) + if ( (p = find_domain_by_id(thread)) == NULL) strcpy (pdb_out_buffer, "E00"); else strcpy (pdb_out_buffer, "OK"); @@ -746,7 +814,7 @@ int pdb_handle_exception(int exceptionVector, void pdb_key_pressed(u_char key, void *dev_id, struct pt_regs *regs) { - pdb_handle_exception(136, regs); + pdb_handle_exception(KEYPRESS_EXCEPTION, regs); return; } diff --git a/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c b/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c index 2f6bfe5fd4..883cee38fc 100644 --- a/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c +++ b/xenolinux-2.4.24-sparse/arch/xeno/drivers/block/xl_block.c @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -212,6 +213,10 @@ int xenolinux_block_ioctl(struct inode *inode, struct file *filep, if ( put_user(0, (byte *)(argument + i)) ) return -EFAULT; return 0; + case SCSI_IOCTL_GET_BUS_NUMBER: + DPRINTK("FIXME: SCSI_IOCTL_GET_BUS_NUMBER ioctl in xl_block"); + return -ENOSYS; + default: printk(KERN_ALERT "ioctl %08x not supported by xl_block\n", command); return -ENOSYS; -- 2.30.2